﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MostPopular.ViewModels"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:NYTimes="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" 
    xmlns:NYTimes_ValueConverters="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit"
    x:Class="MostPopular.CommentsPage"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    d:DataContext="{d:DesignInstance local:MostPopularItemComments, IsDesignTimeCreatable=True}"
    shell:SystemTray.IsVisible="True">

	<phone:PhoneApplicationPage.Resources>
		<NYTimes_ValueConverters:NumericFormatConverter x:Key="NumericFormatConverter"/>
		<NYTimes_ValueConverters:DateTimeConverter x:Key="DateTimeConverter"/>
		<DataTemplate x:Key="CommentTemplate">
			<Border CornerRadius="10" Padding="8" Margin="0,0,0,8">
				<Border.Background>
					<SolidColorBrush Color="{StaticResource PhoneChromeColor}"/>
				</Border.Background>
				<StackPanel>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBlock x:Name="DisplayName" Text="{Binding DisplayName}" Margin="0,0,39,0" d:LayoutOverrides="Width, Height">
							<TextBlock.Foreground>
								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
							</TextBlock.Foreground>
						</TextBlock>
						<TextBlock x:Name="Location" Text="{Binding Location}" HorizontalAlignment="Right" d:LayoutOverrides="Height" Grid.Column="1"/>
					</Grid>
					<TextBlock x:Name="ApproveDate" Text="{Binding ApproveDate}">
						<TextBlock.Foreground>
							<SolidColorBrush Color="{StaticResource PhoneSubtleColor}"/>
						</TextBlock.Foreground>
					</TextBlock>
					<StackPanel>
						<TextBlock x:Name="Body" Text="{Binding Body}" TextWrapping="Wrap"/>
						<StackPanel Orientation="Horizontal" Margin="8,0,0,0">
							<TextBlock TextWrapping="Wrap" Text="Recommended by ">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneSubtleColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
							<TextBlock x:Name="Recommendations" Text="{Binding Recommendations}">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneSubtleColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
							<TextBlock TextWrapping="Wrap" Text=" readers">
								<TextBlock.Foreground>
									<SolidColorBrush Color="{StaticResource PhoneSubtleColor}"/>
								</TextBlock.Foreground>
							</TextBlock>
						</StackPanel>
					</StackPanel>
				</StackPanel>
			</Border>
		</DataTemplate>
		<Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="BorderThickness" Value="0"/>
			<Setter Property="BorderBrush" Value="Transparent"/>
			<Setter Property="Padding" Value="0"/>
			<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
			<Setter Property="VerticalContentAlignment" Value="Top"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="SelectionStates">
									<VisualState x:Name="Unselected"/>
									<VisualState x:Name="Selected">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</phone:PhoneApplicationPage.Resources>
 
    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

	<phone:PhoneApplicationPage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</phone:PhoneApplicationPage.FontFamily>
	<phone:PhoneApplicationPage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</phone:PhoneApplicationPage.FontSize>
	<phone:PhoneApplicationPage.Foreground>
		<StaticResource ResourceKey="PhoneForegroundBrush"/>
	</phone:PhoneApplicationPage.Foreground>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="NEW YORK TIMES MOST POPULAR" Style="{StaticResource PhoneTextNormalStyle}"/>
            <StackPanel Orientation="Horizontal" Margin="9,-7,0,0">
                <TextBlock Margin="0" Text="{Binding Comments.TotalComments, ConverterParameter=n0, Converter={StaticResource NumericFormatConverter}, Mode=OneWay}" Style="{StaticResource PhoneTextTitle1Style}"/>
                <TextBlock x:Name="PageTitle" Margin="0" Text=" comments" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        	<Grid.RowDefinitions>
        		<RowDefinition Height="Auto"/>
        		<RowDefinition/>
        	</Grid.RowDefinitions>
        	<TextBlock x:Name="ArticleTitle" TextWrapping="Wrap" Text="{Binding Item.Title}" Style="{StaticResource PhoneTextTitle2Style}"/>
            <ListBox ItemTemplate="{StaticResource CommentTemplate}" ItemsSource="{Binding Comments.Results}" Grid.Row="1"  HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource ListBoxItemStyle1}"/>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
